<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>
    <jsp:include page="common.jsp"></jsp:include>
</head>
<body>
<form method="post" action="">
    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder"> 留言管理</strong></div>
        <div class="padding border-bottom">
            <ul class="search">
                <li>
                    <button type="button"  class="button border-green" id="checkall"><span class="icon-check"></span> 全选</button>
                    <button type="submit" class="button border-red"><span class="icon-trash-o"></span> 批量删除</button>
                     <a class="button border-green" href="${ctx}/manage/news_add.do" ><span class="icon-save"></span> 添加</a>
                </li>
            </ul>
        </div>
        <table class="table table-hover text-center">
            <tr>
                <th width="120">ID</th>
                <th>新闻标题</th>
                <th>新闻发布者</th>
                <th>被阅读数</th>
                <th>新闻主图</th>
                <th width="25%">新闻内容</th>
                <th width="120">新闻添加时间</th>
                <th>操作</th>
            </tr>
            <c:forEach var="n" items="${newsList}" varStatus="s">
                <tr>
                    <td><input type="checkbox" name="id[]" value="1" />
                        ${n.news_id}</td>
                    <td>${n.news_title}</td>
                    <td>${n.news_author}</td>
                    <td>${n.news_readnums}</td>
                    <td><img src="${ctx}/static/pc/${n.news_img}"></td>
                    <td>${n.news_title}</td>
                    <td>${n.news_addtime}</td>
                    <td><div class="button-small"> <a class="button border-blue" href="${ctx}/manage/news_update.do?id=${n.news_id}"><span class="icon-edit"></span> 修改</a> </div>
                        <div class="button-small"> <a class="button border-red" href="javascript:void(0)" onclick="return del(${n.news_id})"><span class="icon-trash-o"></span> 删除</a> </div></td>
                </tr>
            </c:forEach>

            <tr>
                <td colspan="8">
                    <div class="pagelist">
                    <jsp:include page="paging.jsp"></jsp:include>
                </div>
                </td>
            </tr>
        </table>
    </div>
</form>

<script type="text/javascript">

    function del(id){
        if(confirm("您确定要删除吗?")){
            $.post("admin_delete.do",{"id":id},function () {
            },"json")
            setTimeout(function () {
                window.location.href = '${ctx}/news/admin_list.do';
            },50)
        }
    }

    $("#checkall").click(function(){
        $("input[name='id[]']").each(function(){
            if (this.checked) {
                this.checked = false;
            }
            else {
                this.checked = true;
            }
        });
    })

    function DelSelect(){
        var Checkbox=false;
        $("input[name='id[]']").each(function(){
            if (this.checked==true) {
                Checkbox=true;
            }
        });
        if (Checkbox){
            var t=confirm("您确认要删除选中的内容吗？");
            if (t==false) return false;
        }
        else{
            alert("请选择您要删除的内容!");
            return false;
        }
    }


</script>

</body></html>